<template>
  <div >
<!--    <v-app-bar color="white">
      <v-btn to="/home"  color="dark" white>home</v-btn>  账号登陆
      <v-spacer></v-spacer>
    </v-app-bar>-->
    <HomeHeader  :type_="type_"></HomeHeader>
    <v-content>
      <v-container ><div class="register-1">
        <i class="iconfont icon-title"></i>

      </div>
        <v-form
                ref="form"
                lazy-validation
        >
          <v-text-field
                  v-model="data._contact"
                  :counter="10"
                  label="账号(手机号)"
                  required
          ></v-text-field>
          <v-text-field
                  v-model="data._password"
                  label="密码"
                  required
          ></v-text-field>
          <div class="text-center">
            <v-btn rounded color="primary" dark @click="_login">登陆</v-btn>

            <div  class="my-2"><v-btn to="/signup" rounded color="primary" dark>注册</v-btn></div>
          </div>
        </v-form></v-container ></v-content>
  </div>
</template>

<script>

export default {
  data() {
    return {
      data:{
        _contact: "",
        _password: "",
     }
    }
  },
  computed: {
    type_() {
      var x='use'
      if (this.$cookies.isKey('username')) {
        if (this.$cookies.get('username') == 0) {
          x= 'adm_ok'
        } else if (this.$cookies.get('username') == 1) {
          x= 'use_ok'
        }
      }
      else {
        x= 'use'
      }
      return x
    }
  },
  methods: {
    _login(){
      var params=this.data
        params._option ='2001'
      this.$http.post(params,2).then((res)=>{
         if(res._data==='成功'){
        document.cookie="username="+this.data._contact+"; expires=Thu, 18 Dec 2043 12:00:00 GMT; path=/";
        this.$router.push({path:'/'})}
      }).catch((err)=>{
        this.response=err
      })
    }
  }
}
</script>

<style>
</style>

